import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'dart:async';
import 'my_demo_messages_all.dart';

class MyDemoLocalizations {

  static MyDemoLocalizations of(BuildContext context) {
    return Localizations.of<MyDemoLocalizations>(context, MyDemoLocalizations);
  }

  static Future<MyDemoLocalizations> load(Locale locale) {
    final String name = locale.countryCode.isEmpty ? locale.languageCode
      : locale.toString();
    
    final String localeName = Intl.canonicalizedLocale(name);
    return initializeMessages(localeName).then((value) {
      Intl.defaultLocale = localeName;
      return MyDemoLocalizations();
    });
  }

  String get title => Intl.message(
    'htllo',
    name: 'title',
    desc: 'demo localizations',
  );

  String greet(String name) => Intl.message(
    'hello $name',
    name: 'greet',
    desc: 'greet someone',
    args: [name],
  );
}

class MyDemoLocalizationsDelegate extends LocalizationsDelegate<MyDemoLocalizations> {
    @override
    bool isSupported(Locale locale) {
      return true;
    }
  
    @override
    Future<MyDemoLocalizations> load(Locale locale) {
      return MyDemoLocalizations.load(locale);
    }
  
    @override
    bool shouldReload(covariant LocalizationsDelegate<MyDemoLocalizations> old) {
      return false;
    }

}